package com.llf.Controller;

import com.llf.Pojo.Content;
import com.llf.Service.ContentServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.ArrayList;

@Controller
public class ControllerContent {
    @Autowired
    private ContentServiceImpl contentService;
    @RequestMapping("/all")
    public String getallcontent(Model model){
        ArrayList<Content> contents = contentService.getall();
        model.addAttribute("contents",contents);
        return "advice";
    }
    @GetMapping("/cdelete/{id}")
    public String contentdelete(@PathVariable("id") Integer id){
        contentService.deleteById(id);
        return "redirect:/all";

    }

}
